package org.homly.admin.tag.product;

import java.util.HashMap;
import java.util.List;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;

import org.homly.service.ProductService;
import org.homly.tool.StringTool;

/*
 * 查询配置
 */
@SuppressWarnings("serial")
public class ConfigListTag extends TagSupport {

	private String name;
	private String status = "1";	//默认查询有效的配置

	@SuppressWarnings("unchecked")
	@Override
	public int doStartTag() throws JspException {

		List<HashMap<String, String>> configs = null;

		Short statusNum = null;
		if (status == null || !StringTool.isNumber(status)) {
			status = "1";
		}
		statusNum = Short.valueOf(status);

		HashMap para = new HashMap();
		para.put("status", statusNum);

		ProductService productService = new ProductService();
		try {
			configs = productService.getConfigs(para);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		pageContext.setAttribute(name, configs);

		return SKIP_BODY;
	}

	public void setName(String name) {
		this.name = name;
	}
	public void setStatus(String status) {
		this.status = status;
	}
}
